﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DBControl;
using System.Web.SessionState;

namespace ProjectX.AjaxCommand
{
    /// <summary>
    /// UpdateUser 的摘要说明
    /// </summary>
    public class UpdateUser : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string email = context.Request.Form["emailbox"];
            string tbname = context.Request.Form["tbname"];
            string updateuser = "UPDATE UserRegister SET [email] = '" + email + "',Tbname='" + tbname + "' WHERE userName='" + context.Session["userNick"] + "'";
            SqlDbHelper sdh = new SqlDbHelper();
            try
            {
                if (sdh.ExecuteNonQuery(updateuser) != 0)
                {
                    context.Response.Write("ok");
                    context.Response.End();
                }
                else
                {
                    context.Response.Write("");
                    context.Response.End();
                }
            }
            catch (Exception)
            {
                context.Response.Write("");
                context.Response.End();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}